<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改站点密码</title>
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <script src="/js/layui/layui.all.js"></script>
    <script src="/admin/js/token.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15>
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <lable class="layui-form-label">站点名称</lable>
                            <div class="layui-input-inline">
                                <input type="text" id="stationName" disabled class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <lable class="layui-form-label">设置密码</lable>
                            <div class="layui-input-inline">
                                <input type="text" id="psd" placeholder="输入密码" autocomplete="off" class="layui-input"
                                       lay-verify="required"
                                >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="edit">修改</button>
                                <button class="layui-btn layui-icon layui-icon-close" id="back">
                                    取消
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
        var $ = layui.$;
        var form = layui.form;
        var data = layui.data("stationdata");
        $("#stationName").val(data.getdata.station_name);
        $("#psd").val(data.getdata.station_password);
        var id = data.getdata.station_id;//站点主键id
        var adminid=data.getdata.station_admin_id
        var adminidnow=layui.data("local_store").token;;//当前登录的用户
        //修改密码的监听事件
        form.on("submit(edit)", function (data) {
            $.ajax({
                type: "post",
                url: "/admin/station/editStationPsdById",
                data: {
                    stationAdminId:adminid,
                    stationId: id,
                    stationPassword: $("#psd").val(),
                    adminidnow:adminidnow
                },
                success: function (res) {
                    if (res.code == 200) {
                        layer.msg("修改成功", {
                            icon: 1,
                            time: 1000
                        });
                        setTimeout(function () {
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index);    //关闭弹出层
                        }, 1500)
                        return;
                    }
                    layer.msg(res.data, {
                        icon: 2
                    })
                },
                error: function () {
                    layer.msg("系统原因修改失败", {
                        icon: 2
                    })
                }
            });
            return false;
        })

        $('#back').click(function () {
            var index = parent.layer.getFrameIndex(window.name) //获取窗口索引
            parent.layer.close(index)    //关闭弹出层
        })
</script>
</body>
</html>